﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using Tank90.Properties;

namespace Tank90
{
    /// <summary>
    /// 爆炸类
    /// </summary>
    public class Blast : Element
    {
        private int count = 0;           //用记指定在加载哪张图片
        private static Image[] blastImg = new Image[]    //图片数组
        {
            Resources.blast11,
            Resources.blast2,
            Resources.blast3,
            Resources.blast4,
            Resources.blast5,
            Resources.blast6,
            Resources.blast7,
        };

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="x">图片的x座标</param>
        /// <param name="y">图片的y座标</param>
        /// <param name="life">图片的生命</param>
        public Blast(int x, int y)
        {
            this.x = x;
            this.y = y;
        }

        /// <summary>
        /// 画出爆炸（动画效果）
        /// </summary>
        /// <param name="g"></param>
        public override void Drawing(Graphics graphics)
        {
            Sound.Play("blast.wav");
            if (count < blastImg.Length)         //当记数器小于图片数量时
            {
                graphics.DrawImage(blastImg[count], this.x, this.y);     //在指定的位置画图
                count++;              //记事器自加
            }
            else                  //当图片都画完后
            {
                MainManager.mainManager.DelGameElement(this);
            }
        }



       
    }
}
